package com.ranjiaqi.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @ClassName textinsert
 * @Description TODO
 * @Author hp
 * @Date 2021/7/16 19:55
 * @Version 1.0
 **/
public class textinsert {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/testjdbc";
        String username = "root";
        String password = "1234";
        Connection connection = DriverManager.getConnection(url, username, password);
        Statement statement = connection.createStatement();
        String sql = "insert into user values (null,'tq','7777','田七')";
        int row = statement.executeUpdate(sql);
        System.out.println("row = " + row);
        if (statement != null) {
            statement.close();
        }
        if (connection != null) {
            connection.close();
        }
    }
}
